<?php
namespace app\member\model;

use app\BaseModel;
use think\facade\Db;

class Stored extends BaseModel
{
    //会员权益表
    protected $name = 'longbing_card_member_stored';

    protected $append = [

        'stored_type'
    ];


    /**
     * @author chenniang
     * @DataTime: 2020-09-11 11:07
     * @功能说明:储值卡的类型
     */
    public function getStoredTypeAttr($value,$data){

        if(!empty($data['id'])){

            $stored_level_model = new StoredLevel();

            $type = $stored_level_model->storedType($data['id']);

            return $type;
        }

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-09 10:37
     * @功能说明:列表
     */
    public function storedList($dis,$page){

        $data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();

        return $data;

    }





    /**
     * @author chenniang
     * @DataTime: 2020-07-15 09:49
     * @功能说明:添加
     */
    public function storedAdd($data){

        $data['create_time'] = time();

        $data['update_time'] = time();

        $data['status']      = 1;

        $res = $this->insert($data);

        return $res;
    }





    /**
     * @author chenniang
     * @DataTime: 2020-04-26 17:08
     * @功能说明:详情
     */
    public function storedInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)?$data->toArray():[];

    }


    /**
     * @author chenniang
     * @DataTime: 2020-04-26 17:13
     * @功能说明:编辑
     */
    public function storedUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }










}